package com.jiubaisoft.myrefresh;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.songdehuai.myrefresh.R;

import java.util.List;

/**
 * Created by songdehuai on 2017/8/14.
 */

public class MainListAdapter extends BaseAdapter {
    private List<String> listDatas;
    private Context context;


    public MainListAdapter(Context context, List<String> listDatas) {
        this.context = context;
        this.listDatas = listDatas;
    }

    private int select = 0;


    public void setSelect(int position) {
        this.select = position;
        this.notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return listDatas.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder = null;
        if (null == holder) {
            view = View.inflate(context, R.layout.item_lv, null);
            holder = new ViewHolder(view);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }
        holder.textView.setText(listDatas.get(i));

        return view;
    }

    static class ViewHolder {

        TextView textView;

        public ViewHolder(View itemView) {
            textView = itemView.findViewById(R.id.item_tv);
        }
    }
}
